;tape tests


	OUTPUT "tapeoutin.rom"

	;defpage 0, $0000, $4000 
    defpage 1, $4000, $4000 
    defpage 2, $8000, $4000 
    ;defpage 3, $C000, $4000 


	page	1

;-----------------------------------------------
;- vram address labels
CHRTBL equ 0x0000
NAMTBL equ 0x1800
CLRTBL equ 0x2000
SPRTBL equ 0x3800
SPRATR equ 0x1B00

FORCLR equ 0xF3E9  ; Foreground color (+1 = background color , +1 border)

JIFFY  equ 0xFC9E

SNSMAT equ 0x0141  ; keyb bios call	


DATA_SIZE	equ	32

romheader:
	byte "AB"
	word BEGIN
	word 0,0,0,0,0,0


BEGIN:

	xor		a
	call	0x005F			;screen 0

	call	0x00C3			;cls

	ld		hl,press_key_msg
	ld		de,0
	ld		bc,13
	call	0x005c
	
	call	0x009f			;wait keystroke


	;write header
	xor		a
	call	0x00EA
	jr		c,error_end
	
	ld		b,DATA_SIZE
	ld		hl,test_string
tape_data_write_loop:
	push	bc
	push	hl
	
	ld		a,[hl]
	call	0x00ED
	jr		c,error_end
	
	pop		hl
	inc		hl
	pop		bc
	djnz	tape_data_write_loop

	call	0x00F0

	
	
	
	
	ld		hl,test_string
	xor		a
	ld		a,[hl]
	push	hl
	pop		de
	inc		de
	ld		bc,DATA_SIZE-1
	ldir							;msg clear
	
	ld		hl,press_key_msg
	ld		de,40
	ld		bc,13
	call	0x005c

	call	0x009f			;wait keystroke
	

	
	xor		a
	call	0x00E1
	jr		c,error_end
	
	ld		b,DATA_SIZE
	ld		hl,test_string
tape_data_read_loop:
	push	bc
	push	hl
	
	call	0x00E4
	jr		c,error_end
	
	pop		hl
	ld		[hl],a
	inc		hl
	pop		bc
	djnz	tape_data_read_loop

	call	0x00E7
	
	
	ld		hl,test_string
	ld		de,80
	ld		bc,DATA_SIZE
	call	0x005c
	
	
	jr		end_end
	
	
	


	
error_end:	
	
	ld		hl,error_msg
	ld		de,160
	ld		bc,6
	call	0x005c
	
	
	
	
	
end_end:	
	
	
	
	jr		$
	

press_key_msg:
	db "Press any key"
error_msg:
	db "Error!"
	
	
test_string:
	db	"There is a way to save this text!!!"
